From e6467b41fccefe1ceb39dd1ed6343290e152be85 Mon Sep 17 00:00:00 2001 From: Sebastien Castiel Date: Tue, 30 Jan 2024 20:07:46 -0500 Subject: Improve receipt scanning --- .../expenses/create-from-receipt-button.tsx | 67 +++++++++++++++------- 1 file changed, 46 insertions(+), 21 deletions(-) (limited to 'src/app/groups/[groupId]') diff --git a/src/app/groups/[groupId]/expenses/create-from-receipt-button.tsx b/src/app/groups/[groupId]/expenses/create-from-receipt-button.tsx index 5feb931..d3f2bcf 100644 --- a/src/app/groups/[groupId]/expenses/create-from-receipt-button.tsx +++ b/src/app/groups/[groupId]/expenses/create-from-receipt-button.tsx @@ -28,7 +28,7 @@ import { useToast } from '@/components/ui/use-toast' import { useMediaQuery } from '@/lib/hooks' import { formatExpenseDate } from '@/lib/utils' import { Category } from '@prisma/client' -import { ChevronRight, Loader2, Receipt } from 'lucide-react' +import { ChevronRight, FileQuestion, Loader2, Receipt } from 'lucide-react' import { getImageData, useS3Upload } from 'next-s3-upload' import Image from 'next/image' import { useRouter } from 'next/navigation' @@ -154,21 +154,27 @@ export function CreateFromReceiptButton({
Title: -
{receiptInfo?.title ?? '…'}
+
{receiptInfo ? receiptInfo.title ?? : '…'}
Category:
- {receiptInfoCategory ? ( -
- - {receiptInfoCategory.grouping} - - {receiptInfoCategory.name} -
+ {receiptInfo ? ( + receiptInfoCategory ? ( +
+ + + {receiptInfoCategory.grouping} + + + {receiptInfoCategory.name} +
+ ) : ( + + ) ) : ( '' || '…' )} @@ -177,10 +183,14 @@ export function CreateFromReceiptButton({
Amount:
- {receiptInfo?.amount ? ( - <> - {groupCurrency} {receiptInfo.amount.toFixed(2)} - + {receiptInfo ? ( + receiptInfo.amount ? ( + <> + {groupCurrency} {receiptInfo.amount.toFixed(2)} + + ) : ( + + ) ) : ( '…' )} @@ -189,16 +199,22 @@ export function CreateFromReceiptButton({
Date:
- {receiptInfo?.date - ? formatExpenseDate( + {receiptInfo ? ( + receiptInfo.date ? ( + formatExpenseDate( new Date(`${receiptInfo?.date}T12:00:00.000Z`), ) - : '…'} + ) : ( + + ) + ) : ( + '…' + )}
-

You’ll be able to edit the expense information after creating it.

+

You’ll be able to edit the expense information next.

@@ -225,6 +241,15 @@ export function CreateFromReceiptButton({ ) } +function Unknown() { + return ( +
+ + Unknown +
+ ) +} + function CreateFromReceiptDialog({ trigger, title, -- cgit v1.3